Fix issue in returning cursor after print_above()#59
Conversation
|
Hi, thanks very much for your PR, indeed I have just a little annoyement when using it, channel echoes does not handle emojis correctly. Some of those characters are larger and to accomodate with that I force the position from where path and signal strength are printed. It should look like :
but with your PR it looks like
cursor moving is done here : meshcore-cli/src/meshcore_cli/meshcore_cli.py Line 257 in 37b8273 using this part of the formated string : If you get this working again, I'll merge the PR ;) |
|
OK, great, on my terminal I don't get the I'll see if I can fix the problem. Originally the code split long lines into multiple, but I didn't bother with that, maybe this is causing that behavior |
|
this is handy to follow repeats from the repeaters |
|
I tried to fix the right-aligned texts now. You might find incidental over-compensation in the case of wide-characters in node names, but that is probably better than characters spilling over into the next line. BTW I do see the benefit of the channel echoes, although in my case incoming traffic usually are a few echoes between the same few repeaters in my area --- but I can see that my repeater picks up the most messages |
|
Hi, I'd suggest you to calculate the position of the cursor by calculating the size of the right aligned text (which only depends on the path length and should not contain emojis) and substracting this from the width of the terminal, this has proven more robust for me Sadly I don't have much time right now :( |
Lots of testing through complicated ssh / mosh tunnels and tmux / screen session managers. Seems more stable now
|
Hi, I'll see if I can test with wide characters in messages. What platform did you use for those screen shots? I always run with Also I see that some unrelated changes got pushed to this branch, I'll see if I can undo these |
e91b176 to
66473ce
Compare
|
Hi, I'm on Linux and the result is consistent between terminal emulators (the screenshot has been made using foot) |
|
is I've seen that macs are not the only platform where there is issue with print_above, I've tried to use a node through ssh with connectbot on an Android phone and messages were printed on the top of the window |
|
I would be curious how the linux terminals work with the
I think the analysis of the AI was that the mix of ansi escape sequences with prompt_toolkit was probably not great. I don't know what |
|
well, with Using ssh/tmux over your terminal does not change the way your terminal handles ansi sequences, that's why it doesn't change anything ... I'm using mccli daily through ssh (to access remote nodes in france), don't use tmux but screen has been working for me too Please, don't send PR generated with AI, you can run AI on the code and get inspiration, but it generally modifies the code out of the scope of what is wanted (and I now understand some rewrites in your code that was not necessary). So take your inspiration, and then write the code exactly as you wish it to be ... Yes it is true that mixing prompt-toolkit and ansi might be bad in some cases. The print_above code was introduced before I use prompt toolkit and if there are some prompt-toolkit bits to do it I'm good with it. but for the moment, the text alignment method I've been using is better (because I don't have to guess the width of the characters) |
|
also, have you tried and ansi-compliant terminal emulator on your mac ? I see there is alacritty available, which works just fine for me on Linux. I'm not asking to avoid making the change, but just so you see how it "should" look Also, when I wrote about the fact that print_above has been introduced before the use of prompt-toolkit (and as it was meant as a mechanism for dealing with the prompt), the idea came to me that maybe I don't even need print-above now, surely prompt-toolkit directly handles output in the terminal while typing in the prompt ... will test that, it might be a lot simpler than I thought ! |
|
OK, thanks, this is clear. I will close this PR, as it is too hard to develop between Linux/mac terminals at the moment. I would not normally submit AI code, but see the disclaimer in my original message, and I would normally write code for Linux, not for other OSs. But circumstances were a little different this time, sorry about all that. I'll keep this as a working branch for myself, as this originally grew out of garbled terminals on my side. Cheers! |
|
no problem, I'll try to refactor the whole print_above thing, and will probably re-read your code to get some ideas ... Can I ask you for testing under mac when I have something ? |
|
that was so easy, just use |
|
@davidavdav can you test please ? from the https://github.com/meshcore-dev/meshcore-cli/tree/refactor-print-above if it works then its a very welcome simplification ;) |
|
I try a few wide chars messages, and it seems to work for me now, with Thanks! |
|
Well, let me thank you too, because I wouldn't have thought about it ... this is so much better now ;) and thanks for reporting back quick too ! |







In my terminal (standard macos text terminal) the
print_above()does not return to the original place (just after the prompt). The problem is related to a mix ofPromptSessionand plainprint(), the DEC terminal escape sequences move the cursor withoutprompt_toolkitknowing about this. For me this results in a garbled terminal.This PR fixes it for me, but I don't have all the use cases, so I don't know what the effect will be in other terminals or OSs.
Full disclosure: the code and analysis was done by cursor (pun not intended). If this is not compliant with your coding policy, feel free to ignore this PR.